﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;

namespace DA
{
    public class Materials_Type_DAL : clsConnect
    {
        private clsConnect cls = new clsConnect();
        #region[Get-Data]
        public DataTable GetMaterials_Type()
        {
            return cls.GetData("sp_tb_Materials_Type_Search");
        }
        public DataTable GetMaterials_TypeDetail_Edit(int id)
        {
            return cls.GetData_ID_Int("sp_tb_Materials_Type_Detail_Edit", "@Materials_Type_Id", id);
        }
        #endregion

        #region[Insert-Update-Delete]
        public bool InsertMaterials_Type(ET.Materials_Type_ET data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Materials_Type_Alias", data.Materials_Type_Alias);
            cls.AddParameter("@Materials_Type_Name", data.Materials_Type_Name);
            cls.AddParameter("@Materials_Type_Note", data.Materials_Type_Note);
            cls.ExecuteNonQuery("sp_tb_Materials_Type_Insert");
            return true;
        }
        public bool UpdateMaterials_Type(ET.Materials_Type_ET data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Materials_Type_Id", data.Materials_Type_Id);
            cls.AddParameter("@Materials_Type_Alias", data.Materials_Type_Alias);
            cls.AddParameter("@Materials_Type_Name", data.Materials_Type_Name);
            cls.AddParameter("@Materials_Type_Note", data.Materials_Type_Note);
            cls.ExecuteNonQuery("sp_tb_Materials_Type_Update");
            return true;
        }
        public bool DeleteMaterials_Type(int id)
        {
            cls.Delete("sp_tb_Materials_Type_Delete", "@Materials_Type_Id", id);
            return true;
        }
        #endregion

        #region[Search-Fillter]
        public DataTable Search(string keywords)
        {
            return cls.Search("sp_tb_Materials_Type_Search", "@KEYWORDS", keywords);
        }
        #endregion
    }
}
